package com.foreknow.demo10;

/**
 * @author shkstart
 * @create 2021-07-29 13:44
 */
public class StringDemo {
    public static void main(String[] args) {
        String s="tom";
        System.out.println(s);
        String s1=s.concat("aaaa");
        System.out.println(s1);
        String substring = s1.substring(1, 3);
        System.out.println(substring);
        System.out.println("hamasdasd".substring(4, 9));
        //拆分字符串
        String str1="aaaa bbb ccc ddd";
        String Ustr1 = str1.toUpperCase();
        String[] newstr = Ustr1.split(" ");
        for (String arr:newstr ) {
            System.out.println(arr);
        }
        String[] newstr2 = str1.split(" ", 2);//根据空格拆分字符串，拆分成指定个数
        for (String arr:newstr2 ) {
            System.out.println(arr);
        }

    }
}
